package com.dxs.Mapper;

import com.dxs.Entity.EntityUser;
import com.dxs.Entity.EntityUserData;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FilesMapper {

    @Insert("insert into userdata(uname, filename, filePath, dataMaker, uid, dataMakerID,typeCode) values (#{uname}, #{filename},  #{filePath}, #{dataMaker}, #{uid}, #{dataMakerID}, #{typeCode})")
    int uploadFile(EntityUserData userData);

    @Select("select * from userdata where uid = #{uid}")
    List<EntityUserData> getUserDataByUid(int uid);

    @Select("select * from users where account = #{account} and password = #{password}")
    EntityUser login(String account, String password);

    @Select("select * from userdata where dataMakerID = #{dataMakerID}")
    EntityUserData getCountByDataMakerID(String dataMakerID);

    @Update("update userdata set filename = #{filename}, filePath = #{filePath}, dataMaker=#{dataMaker} where dataMakerID = #{dataMakerID}")
    int updateUserDataByDataMakerID(EntityUserData userData);

    @Delete("delete from userdata where dataMakerID = #{dataMakerID}")
    int deleteUserDataByDataMakerID(String dataMakerID);

    @Insert("insert into users(uname, account, password, id, status, loginstatus) values(#{username}, #{account}, #{password}, #{id}), #{status}, #{loginstatus})")
    int register(String username, String account, String password, String id, int status, int loginstatus);

}
